package com.j01y.myhooks.Entry;

import android.content.Context;

import com.j01y.myhooks.Hooks.HookTestHandler;
import com.j01y.myhooks.Handlers.SekiroServiceHandler;
import com.j01y.myhooks.Utils.HookHelpers;
import com.j01y.myhooks.Utils.Logger;
import com.j01y.myhooks.Utils.Utils;
import com.virjar.sekiro.api.SekiroClient;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

/**
 * 真正进行Hook操作的类
 */
public class RealEntry implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        Logger.logi(String.format("Begin Real Hook Logic About:%s %s", lpparam.packageName));
        // 取目标app的context
        Context context = HookHelpers.hookContext(lpparam);
        String clientId = Utils.getClientId("/data/data/"+lpparam.packageName);
        Logger.logi("clientId:"+clientId);

        // Step1:根据需要添加注册sekiro客户端
        String group = "gifmaker";  // 手机分组
        SekiroClient.start("serverHostIp",clientId,group).registerHandler(new SekiroServiceHandler());

        // Step2:添加hook处理逻辑入口
        HookTestHandler.wifi(lpparam);

        Logger.logi("RealHook End.");
    }
}
